import xcms.gui.CommonBuilder;

/**
 * Class responsible for building CMS-styled dialogs.
 */
class xcms.gui.DialogBuilder extends xcms.gui.CommonBuilder
{
    /**
     * Creates and returns button with "OK" label.
     *
     * @param parent (Window) The parent window.
     * @param listener (object) The action listener.
     * @param x, y (int) The button position.
     * @return Window
     */
    this.createOkButton = function( parent, listener, x, y )
    {
        return this.createLink(parent, '[   OK   ]', listener, x, y);
    }

    /**
     * Creates and returns button with "Cancel" label.
     *
     * @param parent (Window) The parent window.
     * @param listener (object) The action listener.
     * @param x, y (int) The button position.
     * @return Window
     */
    this.createCancelButton = function( parent, listener, x, y ) {
        return this.createLink(parent, '[ Cancel ]', listener, x, y);
    }

    /**
     * Creates and returns "username" field.
     *
     * @param parent (Window) The parent window.
     * @param x, y (int) The pixel coordinates.
     * @return Window
     */
    this.createUsername = function( parent, x, y ) {
        var field = this.createEdit(parent, x, y);
        field.resize(150, 20);
        return field;
    }

    /**
     * @see CommonBuilder#createPassword
     */
    this.createPassword = override(this.createPassword, function( parent, x, y ) {
        var field = super(parent, x, y);
        field.resize(150, 20);
        return field;
    })

    /**
     * @param parent (Window) The parent window.
     * @param text (string) The message text.
     * @param x, y (int) The pixel coordinates.
     * @return Window
     */
    this.createMessage = function( parent, text, x, y )
    {
        var message = this.createText(parent, '', x, y);
        message.setStyle('font-size', '14px');
        return message;
    }
}